function co(fn) {
    let gen = fn()
    function next(...args) {
        const { value, done } = gen.next()
        if (done) return value;
        if (value.then) {
            return value.then(res => next(res))
        } else {
            return next(value)
        }
    }
    next()
}